import time
from time import sleep
from base.base_page import Base
from elements.add_group_element import *
import allure

class GroupPage(Base):
    @allure.step("输入账号：{user}")
    def input_userName(self,user):
        self.input_texts(*user_ele,0,user)
    @allure.step("输入密码：{password}")
    def input_PassWord(self,password):
        self.input_texts(*pwd_ele,1,password)
    @allure.step("点击登录按钮")
    def click_btn(self):
        time.sleep(2)
        self.click_element(*lo_btn)
    @allure.step("点击用户按钮")
    def click_UserIcon(self):
        sleep(5)
        self.click_elements(*u_btn,1)
    @allure.step("点击用户分组")
    def click_user_group(self):
        self.click_element(*userGroup_ele)
    @allure.step("点击添加分组")
    def click_add_group(self):
        sleep(2)
        self.click_element(*add_group_ele)
    @allure.step("输入分组名称：text")
    def input_group_name(self,text):
        self.text = text
        sleep(2)
        self.input_texts(*input_group_ele,2,self.text)
    @allure.step("点击弹窗中的确定按钮")
    def click_acceptBtn(self):
        self.click_element(*accept_ele)
    @allure.step("断言，是否添加成功")
    def assert_add(self):
        text = self.find_element(*('xpath',f"//*[text()='{self.text}']")).text
        assert text == self.text
    @allure.step("点击删除按钮")
    def click_deleteBtn(self):
        self.click_elements(*delete_ele,-1)
    @allure.step("点击弹窗中的确认按钮")
    def click_acceptBtn(self):
        self.click_elements(*ele_accept_ele,-1)